<div id="<*$controller*>">
<form action="/<*$controller*>/op" method="post" class="form-horizontal">
   <table class="table table-hover table-condensed">
   <thead>
   <tr>
   <th class="span1">&nbsp;</th>
   <th class="span1">显示顺序</th>
   <th class="span4">名称</th>
   <th class="span2">链接</th>
   <th class="span1">首页</th>
   <th class="span1">可用</th>
   <th class="span3">&nbsp;</th>
   <th class="span2">&nbsp;</th>
   <th>&nbsp;</th>
   </tr>
   </thead>
   <tbody>
 <*foreach from=$menulist.0 item=item key=key*>
  <tr>
   <td>&nbsp;</td>
   <td><input type="text" name="orderby[]" value="<*$item.orderby*>" class="span1"></td>
   <td class="span4"><input type="text" name="modename[]" value="<*$item.menu*>" class="span2"></td>
   <td><*$item.menu_en*></td>
   <td><input type="checkbox" name="top[<*$item.menuid*>]" value="<*$item.menuid*>" <*if $item.istopbar eq 1*> checked="checked"<*/if*>></td>
   <td><input type="checkbox" name="hide[<*$item.menuid*>]" value="<*$item.menuid*>" <*if $item.ishidden eq 0*> checked="checked"<*/if*>></td>
   <td><button type="button" class="btn  btn-small" onclick="javascript:editit(<*$item.menuid*>)"><i class="icon-wrench"></i> 编辑</button>&nbsp;&nbsp;<*assign var="id" value=$item.menuid*><*if $menulist.$id*>&nbsp;<*else*><button type="button" class="btn  btn-small" onclick="javascript:deleteit(<*$item.menuid*>)"><i class="icon-remove"></i> 删除</button><*/if*></td>
   <td>&nbsp;</td>
  </tr>
  <input type="hidden" value="<*$item.menuid*>" name="menuid[]" id="menuid"/>
  <*assign var="childid" value=$item.menuid*>
  <*if $menulist.$childid*>
         <*foreach from=$menulist.$childid item=item1 key=key1*>
  <input type="hidden" value="<*$item1.menuid*>" name="menuid[]" id="menuid"/>
              <tr>
               <td>&nbsp;</td>
               <td><input type="text" name="orderby[]" value="<*$item1.orderby*>" class="span1"></td>
               <td class="span4"><div class="board"><input type="text" name="modename[]" value="<*$item1.menu*>" class="span2"></div></td>
               <td><*$item1.menu_en*></td>
               <td><input type="checkbox" name="top[<*$item1.menuid*>]" value="<*$item1.menuid*>" <*if $item1.istopbar eq 1*> checked="checked"<*/if*>></td>
               <td><input type="checkbox" name="hide[<*$item1.menuid*>]" value="<*$item1.menuid*>" <*if $item1.ishidden eq 0*> checked="checked"<*/if*>></td>
               <td><button type="button" class="btn  btn-small" onclick="javascript:editit(<*$item1.menuid*>)"><i class="icon-wrench"></i> 编辑</button>&nbsp;&nbsp;<button type="button" class="btn  btn-small" onclick="javascript:deleteit(<*$item1.menuid*>)"><i class="icon-remove"></i> 删除</button></td>
               <td>&nbsp;</td>
              </tr>
           <*/foreach*>

  <*/if*>
                <tr>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td ><div class="lastboard"><button type="button" class="btn  btn-small" onClick="addit(<*$item.menuid*>)"><i class="icon-plus-sign"></i> 添加子栏目</button> </div></td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
                <td>&nbsp;</td>
             </tr>

  <*/foreach*>
                  <tr>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td ><button type="button" class="btn btn-small" onClick="addit(0)"><i class="icon-plus-sign"></i> 新增栏目</button>
               </td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
              </tr>
  </tbody>
  </table>

<div class="form-actions">
			<button type="submit" class="btn btn-primary btn-large">保存修改</button>
</div>
</form>


</div>

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <form class="form-signin" id="login_form" action="/<*$controller*>/opadd" method="post" onsubmit="return checkLoginForm();">

  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">新增栏目</h3>
  </div>
  <div class="row">
  <div class="modal-body span3">
        <label class="control-label pull-left" >栏目名</label><input type="text" class="input-block-level" autocomplete="off" id="account" name="account" readonly="readonly" >
        <label class="control-label pull-left" >名称</label><input type="text" class="input-block-level" autocomplete="off" placeholder="输入名称"  id="name" name="name" >
        <label class="control-label pull-left" >链接</label><input type="text" class="input-block-level" autocomplete="off" placeholder="controller/action"  id="href" name="href" >
        <label class="control-label" ><input type="checkbox" id="istopbar" name="istopbar" >是否首页</label>
        <label class="control-label" ><input type="checkbox" id="ishidden" name="ishidden" checked="checked" >是否可用</label>
  </div>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-primary" type="submit">保存</button>
  </div>
        </form>
<script type="text/javascript" >
function checkLoginForm(){
	var name=document.getElementById('name').value;
	var href=document.getElementById('href').value;
	if(name=='' || name==null){
		alert('需要输入名称');
		document.getElementById("name").focus();
		return false;
	}
	if(href=='' || href==null){
		alert('需要输入链接');
		document.getElementById("href").focus();
		return false;
	}
	
	return true;
}

function deleteit(id)
{
  if(confirm("删除将不能恢复")){
   window.location='/<*$controller*>/delete/id/'+id;
  }
}

function editit(id)
{
   window.location='/<*$controller*>/edit/id/'+id;
}

function addit(id){
	$(document).ready(function(){
	 //  $(".addnew").click(function(){ // Click to only happen on announce links
		 $("#account").val(id);
		 $('#myModal').modal('show');
	  // });
	});
				
}
</script>
</div>

